/*
  学习目标：监听多个状态的变化

*/
import React, { useEffect, useState } from 'react';

export default function App() {
  const [count, setCount] = useState(0);
  const [msg, setMsg] = useState('Hello React');

  // 1. 合起来写
  useEffect(() => {
    document.title = count + msg;
  }, [count, msg]);

  // 2. 分开写
  useEffect(() => {
    console.log('count  ----->  ', count);
  }, [count]);

  useEffect(() => {
    console.log(' msg ----->  ', msg);
  }, [msg]);
  return (
    <div>
      <button onClick={() => setCount(count + 1)}>点我+1</button>
      <button onClick={() => setMsg(msg + '~')}>点我+~</button>
    </div>
  );
}
